<template>
  <div class="list list-split" :class="{'list-bordered':bordered,'list-sm': size === 'small','list-lg':size === 'large' }">
    <div class="list-header" v-if="showHeader">
      <slot name="header">{{ header }}</slot>
    </div>
    <ListItem v-for="(item,index) in data" :key="index" :item="item">
    </ListItem>
    <div class="list-footer" v-if="showFooter">
      <slot name="footer">{{ footer }}</slot>
    </div>
  </div>
</template>
<script>
import ListItem from './ListItem'
export default {
  name: 'List',
  components: { ListItem },
  data() {
    return {
      showHeader: false,
      showFooter: false
    }
  },
  props: {
    header: {
      type: String
    },
    footer: {
      type: String
    },
    size: {
      type: String,
      default: 'default'
    },
    bordered: {
      type: Boolean,
      default: false
    },
    data: {
      type: Array
    }
  },
  mounted() {
    this.showHeader = this.header || this.$slots.header !== undefined
    this.showFooter = this.footer || this.$slots.footer !== undefined
  }
}
</script>
<style>
.list {
  font-family: 'Helvetica Neue For Number', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
    'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', 'Helvetica Neue', Helvetica, Arial,
    sans-serif;
  font-size: 14px;
  line-height: 1.5;
  color: rgba(0, 0, 0, 0.65);
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  list-style: none;
  position: relative;
}

.list * {
  outline: none;
}

.list-pagination {
  margin-top: 24px;
  text-align: right;
}

.list-more {
  margin-top: 12px;
  text-align: center;
}

.list-more button {
  padding-left: 32px;
  padding-right: 32px;
}

.list-spin {
  text-align: center;
  min-height: 40px;
}

.list-empty-text {
  color: rgba(0, 0, 0, 0.45);
  font-size: 14px;
  padding: 16px;
  text-align: center;
}

.list-item {
  align-items: center;
  display: flex;
  padding-top: 12px;
  padding-bottom: 12px;
}

.list-item-meta {
  align-items: flex-start;
  display: flex;
  font-size: 0;
}

.list-item-meta-avatar {
  flex: 0;
  margin-right: 16px;
}

.list-item-meta-content {
  flex: 1 0;
}

.list-item-meta-title {
  color: rgba(0, 0, 0, 0.65);
  margin-bottom: 4px;
  font-size: 14px;
  line-height: 22px;
  font-weight: 500;
}

.list-item-meta-title > a {
  color: rgba(0, 0, 0, 0.65);
  transition: all 0.3s;
}

.list-item-meta-title > a:hover {
  color: #1890ff;
}

.list-item-meta-description {
  color: rgba(0, 0, 0, 0.45);
  font-size: 14px;
  line-height: 22px;
}

.list-item-content {
  display: flex;
  flex: 1;
  justify-content: flex-end;
}

.list-item-content-single {
  justify-content: flex-start;
}

.list-item-action {
  font-size: 0;
  flex: 0 0 auto;
  margin-left: 48px;
  padding: 0;
  list-style: none;
}

.list-item-action > li {
  display: inline-block;
  color: rgba(0, 0, 0, 0.45);
  cursor: pointer;
  padding: 0 8px;
  position: relative;
  font-size: 14px;
  line-height: 22px;
  text-align: center;
}

.list-item-action > li:first-child {
  padding-left: 0;
}

.list-item-action-split {
  background-color: #e8e8e8;
  margin-top: -7px;
  position: absolute;
  top: 50%;
  right: 0;
  width: 1px;
  height: 14px;
}

.list-item-main {
  display: flex;
  flex: 1;
}

.list-item-extra {
  flex: 0;
}

.list-header,
.list-footer {
  padding-top: 12px;
  padding-bottom: 12px;
}

.list-split .list-item {
  border-bottom: 1px solid #e8e8e8;
}

.list-split .list-item:last-child {
  border-bottom: none;
}

.list-split .list-header {
  border-bottom: 1px solid #e8e8e8;
}

.list-loading .spin-nested-loading {
  min-height: 32px;
}

.list-bordered {
  border-radius: 4px;
  border: 1px solid #d9d9d9;
}

.list-bordered .list-header {
  padding-left: 24px;
  padding-right: 24px;
}

.list-bordered .list-footer {
  padding-left: 24px;
  padding-right: 24px;
}

.list-bordered .list-item {
  border-bottom: 1px solid #e8e8e8;
  padding-left: 24px;
  padding-right: 24px;
}

.list-something-after-last-item .list-item:last-child {
  border-bottom: 1px solid #e8e8e8;
}

.list-bordered.list-lg .list-header,
.list-bordered.list-lg .list-footer {
  padding: 16px 24px;
}

.list-bordered.list-sm .list-item {
  padding-left: 16px;
  padding-right: 16px;
}

.list-bordered.list-sm .list-header,
.list-bordered.list-sm .list-footer {
  padding: 8px 16px;
}

.list-lg .list-item {
  padding-top: 16px;
  padding-bottom: 16px;
}

.list-sm .list-item {
  padding-top: 8px;
  padding-bottom: 8px;
}

.list-vertical .list-item {
  display: block;
}

.list-vertical .list-item-extra-wrap {
  display: flex;
}

.list-vertical .list-item-main {
  display: block;
  flex: 1;
}

.list-vertical .list-item-extra {
  margin-left: 58px;
  flex: 0;
}

.list-vertical .list-item-meta {
  margin-bottom: 16px;
}

.list-vertical .list-item-meta-avatar {
  display: none;
}

.list-vertical .list-item-meta-title {
  color: rgba(0, 0, 0, 0.85);
  margin-bottom: 12px;
  font-size: 16px;
  line-height: 24px;
}

.list-vertical .list-item-content {
  display: block;
  color: rgba(0, 0, 0, 0.65);
  font-size: 14px;
  margin-bottom: 16px;
}

.list-vertical .list-item-action {
  margin-left: auto;
}

.list-vertical .list-item-action > li {
  padding: 0 16px;
}

.list-vertical .list-item-action > li:first-child {
  padding-left: 0;
}

.list-grid .list-item {
  border-bottom: none;
  padding-top: 0;
  padding-bottom: 0;
  margin-bottom: 20px;
}

.list-grid .list-item-content {
  display: block;
}

.list-empty {
  color: rgba(0, 0, 0, 0.45);
  padding: 16px 0;
  font-size: 12px;
  text-align: center;
}

@media screen and (max-width: 768px) {
  .list-item-action {
    margin-left: 24px;
  }
  .list-vertical .list-item-extra {
    margin-left: 24px;
  }
}

@media screen and (max-width: 480px) {
  .list-item {
    flex-wrap: wrap;
  }
  .list-item-action {
    margin-left: 12px;
  }
  .list-vertical .list-item-extra-wrap {
    flex-wrap: wrap-reverse;
  }
  .list-vertical .list-item-main {
    min-width: 220px;
  }
  .list-vertical .list-item-extra {
    margin-left: 0;
  }
}
</style>
